<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>平台页面</title>
    <script src="../layui/lay/modules/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="../bootstrap核心/bootstrap.min.css">
    <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
    <!-- 生成弹框、提示框、下拉菜单的 -->
    <script type="text/javascript" src="../bootstrap核心/popper.min.js"></script>
    <!-- bootstrap的js，用于响应事件 -->
    <script type="text/javascript" src="../bootstrap核心/bootstrap.min.js"></script>
    <script src="../layui/layui.js"></script>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all"/>
    <STYLE>
        .oneGym{
            width: 230px;
            height: 150px;
            text-align: center;
            float: left;
        }
        a{
            text-decoration: none
        }
        body{
            background-color: rgba(0,0,0,0.05);
        }
        #mainContent{
            width: 100%;
            height: auto;
            text-align: center;
        }
        #mainContent button{
            float: left;
            margin-left: 20%;
        }
        .pagination{
            width: 1000px;
            height: 60px;
            float: left;
        }
        .pages button{
            width: 50px;
            height: 40px;
            margin-left: 10px;
        }
        body .layui-open-setbgc .layui-layer-content{background: #f2f2f2;}
        .input-group{
            margin-top: 30px;
        }
        .input-group-btn{
            margin-top: 10px;
        }
        table{
            line-height: 20px;
        }
    </STYLE>
</head>
<body>
    <script>
        $(function () {
            //静态包含头部文件
            $.ajax({
                type: "get",
                url: "platformAndGymHead.html",
                async: true,
                success: function (data) {
                    $("#header").html(data);
                }
            })
        })


        function findGyms(currentPage) {
            $.ajax({
                url:'/platForm/findGyms',
                type:'post',
                data:{
                    page:currentPage,
                },
                dataType:'json',
                success:function (data) {
                    var content='<fieldset class="layui-elem-field" style="width: 80%;margin-top: 15px">'+
                        '<legend style="line-height: 50px;font-size: 30px">所有场馆</legend>'+
                        '<div class="layui-field-box">'+
                        '<div id="allGyms">'+
                        '</div>' +
                        '</div>' +
                        '</fieldset>'
                    content+='<table class="table table-bordered table-hover" style="width: 1800px;float: left;">'
                        +'<thead>'
                        +'<tr style="background-color: #545b62">'
                        +'<th>简图</th>'
                        +'<th>账户</th>'
                        +'<th>场馆名</th>'
                        +'<th style="width: 500px">介绍</th>'
                        +'<th>地址</th>'
                        +'<th>签约状态</th>'
                        +'</tr>'
                        +'</thead>'
                        +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){
                        var po=data.rows[i];
                        var state='';
                        if (po.gState==0){
                            state='<div style="width: 50px;height: 20px;background-color: #5FB878; margin-left: 40%;color: white">已签约</div>'
                        }else{
                            state='<div style="width: 50px;height: 20px;background-color: #b21f2d; margin-left: 40%;color: white">未签约</div>'
                        }
                        content+='<tr style="color: black">'
                            +'<td><img src="../image/'+po.gImage+'" height="20px" width="40px"></td>'
                            +'<td>'+po.gAccount+'</td>'
                            +'<td>'+po.gName+'</td>'
                            +'<td>'+po.gIntroduction+'</td>'
                            +'<td>'+po.gAddress+'</td>'
                            +'<td>'+state+'</td>'
                            +'</tr>'
                    }
                    content+='</tbody></table>';
                    content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                        '<ul class="pagination">' +
                        '<li class="page-item"><a class="page-link" onclick="prePagefindGyms('+currentPage+')">前一页</a></li>';
                    for(var i=0;i<data.total;i++){
                        var page=i+1;
                        content+='<li class="page-item"><a class="page-link" onclick="findGyms('+page+')">'+page+'</a></li>'
                    };
                    content+='<li class="page-item"><a class="page-link" onclick="nextPagefindGyms('+currentPage+','+data.total+')">下一页</a></li>' +
                        '</ul>' +
                        '</div>';
                    $("#mainContent").html(content);
                }
            })
        }
        function nextPagefindGyms(currentPage,totalPage){
            if(currentPage<totalPage){
                findGyms(currentPage+1)
            }
        }
        function prePagefindGyms(currentPage){
            if(currentPage>1){
                findGyms(currentPage-1)
            }
        }


        function findGymSignRequest(currentPage) {
            $.ajax({
                url:'/platForm/findGymSignRequest',
                type:'post',
                data:{
                    page:currentPage,
                },
                dataType:'json',
                success:function (data) {
                    var content='<table class="table table-bordered table-hover" style="width: 1800px;float: left;">'
                        +'<thead>'
                        +'<tr style="background-color: #545b62">'
                        +'<th>审核id</th>'
                        +'<th>场馆名</th>'
                        +'<th>平台分成</th>'
                        +'<th>平台入驻费</th>'
                        +'<th>请求时间</th>'
                        +'<th></th>'
                        +'</tr>'
                        +'</thead>'
                        +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){
                        var po=data.rows[i];
                        content+='<tr style="color: black">'
                            +'<td>'+po.gaId+'</td>'
                            +'<td>'+po.gName+'</td>'
                            +'<td>'+po.gaPlatformratio+'</td>'
                            +'<td>'+po.gaJoinbanlance+'</td>'
                            +'<td>'+po.gaUpdatetime+'</td>'
                            +'<td><button type="button" class="btn btn-info" onclick="passContract('+po.gaId+','+currentPage+')">通过</button><button type="button" class="btn btn-danger" onclick="refuseContract('+po.gaId+','+currentPage+')">拒绝</button><br></td>'
                            +'</tr>'
                    }
                    content+='</tbody>'
                        +'</table>';
                    content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                        '<ul class="pagination">' +
                        '<li class="page-item"><a class="page-link" onclick="prePageSign('+currentPage+')">前一页</a></li>';
                    for(var i=0;i<data.total;i++){
                        var page=i+1;
                        content+='<li class="page-item"><a class="page-link" onclick="findGymSignRequest('+page+')">'+page+'</a></li>'
                    };
                    content+='<li class="page-item"><a class="page-link" onclick="nextPageSign('+currentPage+','+data.total+')">下一页</a></li>' +
                        '</ul>' +
                        '</div>';
                    $("#mainContent").html(content);
                }
            })
        }
        function nextPageSign(currentPage,totalPage){
            if(currentPage<totalPage){
                findGymSignRequest(currentPage+1)
            }
        }
        function prePageSign(currentPage){
            if(currentPage>1){
                findGymSignRequest(currentPage-1)
            }
        }
        function passContract(gaId,currentPage) {
            layui.use('layer', function() { //独立版的layer无需执行这一句
                var $ = layui.jquery, layer = layui.layer;
                layer.open({
                    content: '确定与该场馆签约吗？',
                    btn: ["<i class=\"layui-icon\">&#xe605;</i>", "<i class=\"layui-icon\">&#x1006;</i>"],
                    yes: function (index) {
                        $.ajax({
                            url:'/platForm/GymContract',
                            type:'get',
                            data:{
                                gaid:gaId,
                                flag:1,
                            },
                            success:function (data) {
                                layer.alert("<div style='text-align: center'><i class=\"layui-icon\" style='font-size: 30px; color: #009E94'>&#xe60c;</i>签约成功！</div>")
                                findGymSignRequest(currentPage)
                            }
                        })
                        layer.close(index);
                    },
                    btn2: function (index) {
                    }
                })
            })
        }
        function refuseContract(gaId,currentPage){
            layui.use('layer', function() { //独立版的layer无需执行这一句
                var $ = layui.jquery, layer = layui.layer;
                layer.open({
                    content: '确定拒绝该场馆的签约吗？',
                    btn: ["<i class=\"layui-icon\">&#xe605;</i>", "<i class=\"layui-icon\">&#x1006;</i>"],
                    yes: function (index) {
                        $.ajax({
                            url:'/platForm/GymContract',
                            type:'post',
                            data:{
                                gaid:gaId,
                                flag:0,
                            },
                            success:function (data) {
                                layer.alert("已拒绝场馆的签约")
                                findGymSignRequest(currentPage)
                            }
                        })
                        layer.close(index);
                    },
                    btn2: function (index) {
                    }
                })
            })
        }


        function findGymSignRequestForRescission(currentPage) {
            $.ajax({
                url:'/platForm/findGymsByStateZero',
                type:'post',
                data:{
                  page:currentPage,
                },
                dataType:'json',
                success:function (data) {
                    var content='<table class="table table-bordered table-hover" style="width: 1800px;float: left;">'
                        +'<thead>'
                        +'<tr style="background-color: #545b62">'
                        +'<th>场馆名</th>'
                        +'<th>介绍</th>'
                        +'<th></th>'
                        +'</tr>'
                        +'</thead>'
                        +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){

                        var po=data.rows[i];
                        content+='<tr style="color: black">'
                            +'<td>'+po.gName+'</td>'
                            +'<td>'+po.gIntroduction+'</td>'
                            +'<td><button type="button" class="btn btn-danger" onclick="rescission('+po.gId+','+currentPage+')">解约</button><br></td>'
                            +'</tr>'
                    }
                    content+='</tbody></table>';
                    content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                        '<ul class="pagination">' +
                        '<li class="page-item"><a class="page-link" onclick="prePage('+currentPage+')">前一页</a></li>';
                    for(var i=0;i<data.total;i++){
                        var page=i+1;
                        content+='<li class="page-item"><a class="page-link" onclick="findGymSignRequestForRescission('+page+')">'+page+'</a></li>'
                    };
                    content+='<li class="page-item"><a class="page-link" onclick="nextPage('+currentPage+','+data.total+')">下一页</a></li>' +
                        '</ul>' +
                        '</div>';
                    $("#mainContent").html(content);
                }
            })
        }
        function nextPage(currentPage,totalPage){
            if(currentPage<totalPage){
                findGymSignRequestForRescission(currentPage+1)
            }
        }
        function prePage(currentPage){
            if(currentPage>1){
                findGymSignRequestForRescission(currentPage-1)
            }
        }
        function rescission(gId,currentPage) {
            layui.use('layer', function() { //独立版的layer无需执行这一句
                var $ = layui.jquery, layer = layui.layer;
                layer.open({
                    content: '确定与该场馆解约吗？',
                    btn: ["<i class=\"layui-icon\">&#xe605;</i>", "<i class=\"layui-icon\">&#x1006;</i>"],
                    yes: function (index) {
                        $.ajax({
                            url:'/platForm/rescissionWithGym',
                            type:'post',
                            data:{
                                gid:gId
                            },
                            success:function () {
                                layer.alert("解约成功")
                                findGymSignRequestForRescission(currentPage)
                            }
                        })
                        layer.close(index);
                    },
                    btn2: function (index) {
                    }
                })
            })
        }


        function findTrainersByStateOne(currentPage) {
            $.ajax({
                url:'/platForm/findTrainersByStateOne',
                type:'get',
                data:{
                    page:currentPage,
                },
                dataType:'json',
                success:function (data) {
                    var content='<table class="table table-bordered table-hover" style="width: 1800px;float: left;">'
                        +'<thead>'
                        +'<tr style="background-color: #545b62">'
                        +'<th>头像</th>'
                        +'<th>账号</th>'
                        +'<th>姓名</th>'
                        +'<th>介绍</th>'
                        +'<th>课时费</th>'
                        +'<th>地址</th>'
                        +'<th>工作方式</th>'
                        +'<th>综合评价</th>'
                        +'<th></th>'
                        +'</tr>'
                        +'</thead>'
                        +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){
                        var po=data.rows[i];
                        var count=0;
                        var star='';
                        for (var j=0;j<=po.star-1;j++){
                            star+='<i class="layui-icon" style="font-size: 20px; color: #fd7e14;float: left;margin-left: 5px">&#xe67a;</i>'
                            count++;
                        }
                        if((po.star-count)>0&&(po.star-count<0.5)){
                            star+='<i class="layui-icon" style="font-size: 20px; color: #fd7e14;float: left;margin-left: 5px">&#xe6c9;</i>'
                        }else if(po.star-count>0.5){
                            star+='<i class="layui-icon" style="font-size: 20px; color: #fd7e14;float: left;margin-left: 5px">&#xe67a;</i>'
                        }
                        if (po.star==null){
                            star='该教练还未完成过订单';
                        }
                        var role='';
                        if (po.tRole==0){
                            role='全职';
                        }else{
                            role='兼职'
                        }
                        content+='<tr style="color: black">'
                            +'<td><img src="../image/'+po.tImage+'" width="60px" height="40px"></td>'
                            +'<td>'+po.tAccount+'</td>'
                            +'<td>'+po.tName+'</td>'
                            +'<td>'+po.tIntroduction+'</td>'
                            +'<td>'+po.tValue+'</td>'
                            +'<td>'+po.tAddress+'</td>'
                            +'<td>'+role+'</td>'
                            +'<td>'+star+'</td>'
                            +'<td><button type="button" class="btn btn-danger" onclick="banTrainer('+po.tId+','+currentPage+')">禁用</button><br></td>'
                            +'</tr>'
                    }
                    content+='</tbody>'
                        +'</table>';
                    content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                        '<ul class="pagination">' +
                        '<li class="page-item"><a class="page-link" onclick="prePageStateOne('+currentPage+')">前一页</a></li>';
                    for(var i=0;i<data.total;i++){
                        var page=i+1;
                        content+='<li class="page-item"><a class="page-link" onclick="findTrainersByStateOne('+page+')">'+page+'</a></li>'
                    };
                    content+='<li class="page-item"><a class="page-link" onclick="nextPageStateOne('+currentPage+','+data.total+')">下一页</a></li>' +
                        '</ul>' +
                        '</div>';
                    $("#mainContent").html(content);
                }
            })
        }
        function nextPageStateOne(currentPage,totalPage){
            if(currentPage<totalPage){
                findTrainersByStateOne(currentPage+1)
            }
        }
        function prePageStateOne(currentPage){
            if(currentPage>1){
                findTrainersByStateOne(currentPage-1)
            }
        }
        function banTrainer(tid,currentPage) {
            layui.use('layer', function() { //独立版的layer无需执行这一句
                var $ = layui.jquery, layer = layui.layer;
                layer.open({
                    content: '确定禁用该教练吗？',
                    btn: ["<i class=\"layui-icon\">&#xe605;</i>", "<i class=\"layui-icon\">&#x1006;</i>"],
                    yes: function (index) {
                        $.ajax({
                            url:'/platForm/trainerBan',
                            type:'post',
                            data:{
                                tid:tid
                            },
                            success:function () {
                                layer.alert("该教练已被禁用")
                                findTrainersByStateOne(currentPage)
                            }
                        })
                        layer.close(index);
                    },
                    btn2: function (index) {
                    }
                })
            })
        }


        function findTrainersByStateTwo(currentPage) {
            $.ajax({
                url:'/platForm/findTrainersByStateTwo',
                type:'get',
                data:{
                    page:currentPage,
                },
                dataType:'json',
                success:function (data) {
                    var content='<table class="table table-bordered table-hover" style="width: 1800px;float: left;">'
                        +'<thead>'
                        +'<tr style="background-color: #545b62">'
                        +'<th>头像</th>'
                        +'<th>账号</th>'
                        +'<th>姓名</th>'
                        +'<th>介绍</th>'
                        +'<th>课时费</th>'
                        +'<th>地址</th>'
                        +'<th>工作方式</th>'
                        +'<th></th>'
                        +'</tr>'
                        +'</thead>'
                        +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){
                        var po=data.rows[i];
                        var role='';
                        if (po.tRole==0){
                            role='全职';
                        }else{
                            role='兼职'
                        }
                        content+='<tr style="color: black">'
                            +'<td><img src="../image/'+po.tImage+'" width="60px" height="40px"></td>'
                            +'<td>'+po.tAccount+'</td>'
                            +'<td>'+po.tName+'</td>'
                            +'<td>'+po.tIntroduction+'</td>'
                            +'<td>'+po.tValue+'</td>'
                            +'<td>'+po.tAddress+'</td>'
                            +'<td>'+role+'</td>'
                            +'<td><button type="button" class="btn btn-success" onclick="trainerUnblocked('+po.tId+','+currentPage+')">解禁</button><br></td>'
                            +'</tr>'
                    }
                    content+='</tbody>'
                        +'</table>';
                    content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                        '<ul class="pagination">' +
                        '<li class="page-item"><a class="page-link" onclick="prePageStateTwo('+currentPage+')">前一页</a></li>';
                    for(var i=0;i<data.total;i++){
                        var page=i+1;
                        content+='<li class="page-item"><a class="page-link" onclick="findTrainersByStateTwo('+page+')">'+page+'</a></li>'
                    };
                    content+='<li class="page-item"><a class="page-link" onclick="nextPageStateTwo('+currentPage+','+data.total+')">下一页</a></li>' +
                        '</ul>' +
                        '</div>';
                    $("#mainContent").html(content);
                }
            })
        }
        function nextPageStateTwo(currentPage,totalPage){
            if(currentPage<totalPage){
                findTrainersByStateTwo(currentPage+1)
            }
        }
        function prePageStateTwo(currentPage){
            if(currentPage>1){
                findTrainersByStateTwo(currentPage-1)
            }
        }
        function trainerUnblocked(tid,currentPage) {
            layui.use('layer', function() { //独立版的layer无需执行这一句
                var $ = layui.jquery, layer = layui.layer;
                layer.open({
                    content: '确定解禁该教练吗？',
                    btn: ["<i class=\"layui-icon\">&#xe605;</i>", "<i class=\"layui-icon\">&#x1006;</i>"],
                    yes: function (index) {
                        $.ajax({
                            url:'/platForm/trainerUnblocked',
                            type:'post',
                            data:{
                                tid:tid
                            },
                            success:function () {
                                layer.alert("<div style='text-align: center'><i class=\"layui-icon\" style='font-size: 30px;color: #009E94'>&#x1005;</i>该教练成功解禁，目前为未审核状态</div>");
                                findTrainersByStateTwo(currentPage)
                            }
                        })
                        layer.close(index);
                    },
                    btn2: function (index) {
                    }
                })
            })
        }


        function findTrainersByStateZero(currentPage) {
            $.ajax({
                url:'/platForm/findTrainersByStateZero',
                type:'get',
                data:{
                    page:currentPage,
                },
                dataType:'json',
                success:function (data) {
                    var content='<table class="table table-bordered table-hover" style="width: 1800px;float: left;">'
                        +'<thead>'
                        +'<tr style="background-color: #545b62">'
                        +'<th>头像</th>'
                        +'<th>账号</th>'
                        +'<th>姓名</th>'
                        +'<th>介绍</th>'
                        +'<th>课时费</th>'
                        +'<th>地址</th>'
                        +'<th>工作方式</th>'
                        +'<th></th>'
                        +'</tr>'
                        +'</thead>'
                        +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){
                        var po=data.rows[i];
                        var role='';
                        if (po.tRole==0){
                            role='全职';
                        }else{
                            role='兼职'
                        }
                        content+='<tr style="color: black">'
                            +'<td><img src="../image/'+po.tImage+'" width="60px" height="40px"></td>'
                            +'<td>'+po.tAccount+'</td>'
                            +'<td>'+po.tName+'</td>'
                            +'<td>'+po.tIntroduction+'</td>'
                            +'<td>'+po.tValue+'</td>'
                            +'<td>'+po.tAddress+'</td>'
                            +'<td>'+role+'</td>'
                            +'<td><button type="button" class="btn btn-info" onclick="auditTrainer('+po.tId+','+currentPage+')">通过</button><br></td>'
                            +'</tr>'
                    }
                    content+='</tbody>'
                        +'</table>';
                    content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                        '<ul class="pagination">' +
                        '<li class="page-item"><a class="page-link" onclick="prePageStateZero('+currentPage+')">前一页</a></li>';
                    for(var i=0;i<data.total;i++){
                        var page=i+1;
                        content+='<li class="page-item"><a class="page-link" onclick="findTrainersByStateZero('+page+')">'+page+'</a></li>'
                    };
                    content+='<li class="page-item"><a class="page-link" onclick="nextPageStateZero('+currentPage+','+data.total+')">下一页</a></li>' +
                        '</ul>' +
                        '</div>';
                    $("#mainContent").html(content);
                }
            })
        }
        function nextPageStateZero(currentPage,totalPage){
            if(currentPage<totalPage){
                findTrainersByStateZero(currentPage+1)
            }
        }
        function prePageStateZero(currentPage){
            if(currentPage>1){
                findTrainersByStateZero(currentPage-1)
            }
        }
        function auditTrainer(tid,currentPage) {
            layui.use('layer', function() { //独立版的layer无需执行这一句
                var $ = layui.jquery, layer = layui.layer;
                layer.open({
                    content: '确定该教练审核通过吗？',
                    btn: ["<i class=\"layui-icon\">&#xe605;</i>", "<i class=\"layui-icon\">&#x1006;</i>"],
                    yes: function (index) {
                        $.ajax({
                            url:'/platForm/trainerAudit',
                            type:'post',
                            data:{
                                tid:tid,
                                flag:1
                            },
                            success:function () {
                                layer.alert("<div style='font-size: 20px;text-align: center'><i class=\"layui-icon\" style='color: #00FF00;'>&#xe650;</i>审核通过</div>")
                                findTrainersByStateZero(currentPage)
                            }
                        })
                        layer.close(index);
                    },
                    btn2: function (index) {
                    }
                })
            })
        }


        function findStudents(currentPage) {
            $.ajax({
                url:'/platForm/findStudents',
                type:'get',
                data:{
                    page:currentPage,
                },
                dataType:'json',
                success:function (data) {
                    var content='<table class="table table-bordered table-hover" style="width: 1800px;float: left;">'
                        +'<thead>'
                        +'<tr style="background-color: #545b62">'
                        +'<th>头像</th>'
                        +'<th>账号</th>'
                        +'<th>姓名</th>'
                        +'<th>介绍</th>'
                        +'<th>地址</th>'
                        +'<th>状态</th>'
                        +'<th>公开状态</th>'
                        +'</tr>'
                        +'</thead>'
                        +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){
                        var po=data.rows[i];
                        var state='';
                        var infoState='';
                        if (po.sState==0){
                            state='正常'
                        }else{
                            state='禁用'
                        }
                        if (po.sPermission==0){
                            infoState='仅自己可见'
                        }else{
                            infoState='所有人可见'
                        }
                        content+='<tr style="color: black">'
                            +'<td><img src="../image/'+po.sImage+'" width="20px" height="20px"></td>'
                            +'<td>'+po.sAccount+'</td>'
                            +'<td>'+po.sName+'</td>'
                            +'<td>'+po.sIntroduction+'</td>'
                            +'<td>'+po.sAddress+'</td>'
                            +'<td>'+state+'</td>'
                            +'<td>'+infoState+'</td>'
                            +'</tr>'
                    }
                    content+='</tbody>'
                        +'</table>';
                    content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                        '<ul class="pagination">' +
                        '<li class="page-item"><a class="page-link" onclick="prePagefindStudents('+currentPage+')">前一页</a></li>';
                    for(var i=0;i<data.total;i++){
                        var page=i+1;
                        content+='<li class="page-item"><a class="page-link" onclick="findStudents('+page+')">'+page+'</a></li>'
                    };
                    content+='<li class="page-item"><a class="page-link" onclick="nextPagefindStudents('+currentPage+','+data.total+')">下一页</a></li>' +
                        '</ul>' +
                        '</div>';
                    $("#mainContent").html(content);
                }
            })
        }
        function nextPagefindStudents(currentPage,totalPage){
            if(currentPage<totalPage){
                findStudents(currentPage+1)
            }
        }
        function prePagefindStudents(currentPage){
            if(currentPage>1){
                findStudents(currentPage-1)
            }
        }


        function findOrders(currentPage) {
            $.ajax({
                url:'/platForm/findOrders',
                type:'get',
                data:{
                    page:currentPage,
                },
                dataType:'json',
                success:function (data) {
                    var content='<table class="table table-bordered table-hover" style="width: 1800px;float: left;">'
                        +'<thead>'
                        +'<tr style="background-color: #545b62">'
                        +'<th>学员姓名</th>'
                        +'<th>教练姓名</th>'
                        +'<th>订单金额</th>'
                        +'<th>订单号</th>'
                        +'<th>支付宝交易号</th>'
                        +'<th>订单状态</th>'
                        +'<th>教练分成</th>'
                        +'<th>场馆分成</th>'
                        +'<th>平台分成</th>'
                        +'<th>订单创建时间</th>'
                        +'<th>订单更新时间</th>'
                        +'<th>查看评价</th>'
                        +'</tr>'
                        +'</thead>'
                        +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){
                        var po=data.rows[i];
                        var oStates='';
                        if(po.oState=='已完成'){
                            oStates='<td><div style="width: 50px;height: 20px;background-color: #5FB878; margin-left: 40px;color: white">已完成</div></td>'
                        }else {
                            oStates='<td><div style="width: 50px;height: 20px;background-color: #b21f2d; margin-left: 40px;color: white">未完成</div></td>'
                        }
                        content+='<tr style="color: black">'
                            +'<td>'+po.sName+'</td>'
                            +'<td>'+po.tName+'</td>'
                            +'<td>'+po.oBanlance+'</td>'
                            +'<td>'+po.oNum+'</td>'
                            +'<td>'+po.oAlinum+'</td>'
                            + oStates
                            +'<td>'+po.oTrainerbanlance+'</td>'
                            +'<td>'+po.oGymbanlance+'</td>'
                            +'<td>'+po.oPlatformbanlance+'</td>'
                            +'<td>'+po.oCreatetime+'</td>'
                            +'<td>'+po.oUpdatetime+'</td>'
                            +'<td><button type="button" class="btn btn-info" onclick="viewEvaluation('+po.oId+')">查看</button></td>'
                            +'</tr>'
                    }
                    content+='</tbody>'
                        +'</table>';
                    content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                        '<ul class="pagination">' +
                        '<li class="page-item"><a class="page-link" onclick="prePagefindOrders('+currentPage+')">前一页</a></li>';
                    for(var i=0;i<data.total;i++){
                        var page=i+1;
                        content+='<li class="page-item"><a class="page-link" onclick="findOrders('+page+')">'+page+'</a></li>'
                    };
                    content+='<li class="page-item"><a class="page-link" onclick="nextPagefindOrders('+currentPage+','+data.total+')">下一页</a></li>' +
                        '</ul>' +
                        '</div>';
                    $("#mainContent").html(content);
                }
            })
        }
        function nextPagefindOrders(currentPage,totalPage){
            if(currentPage<totalPage){
                findOrders(currentPage+1)
            }
        }
        function prePagefindOrders(currentPage){
            if(currentPage>1){
                findOrders(currentPage-1)
            }
        }
        function viewEvaluation(oid) {
            $.ajax({
                    url:'/platForm/findEvalutionByOid',
                    type:'post',
                    data:{
                        oid:oid,
                    },
                    dataType:'json',
                success:function (data) {
                    var eStar='';
                    for (var i=0;i<data.eStar;i++){
                        eStar+='<i class="layui-icon" style="font-size: 50px; color: #fd7e14;float: left;margin-left: 15px">&#xe67a;</i>'
                    }
                    for (var i=0;i<5-data.eStar;i++){
                        eStar+='<i class="layui-icon" style="font-size: 50px; color: #fd7e14;float: left;margin-left: 15px">&#xe67b;</i>'
                    }
                    var evalution=' <div class="layui-col-md6" style="margin-top: 50px;width: 100%;height: 350px;">' +
                        '      <div class="layui-card">' +
                        '        <div class="layui-card-header" style="font-size: larger">评价详情</div>' +
                        '        <div class="layui-card-body">' +
                       data.eMessage+
                        '        </div>' +
                        '      </div>' +
                        '    </div>'
                    var content='<div style="width: 500px; height: 150px;">' +
                        '<div style="width: 400px; height: 100px; line-height: 100px;margin-left: 50px;margin-top: 20px;">' +
                        eStar+
                        '</div>' +
                            evalution+
                        '</div>';
                        layui.use('layer', function() { //独立版的layer无需执行这一句
                            var $ = layui.jquery, layer = layui.layer;
                                layer.ready(function(){
                                    layer.open({
                                        type: 1,
                                        title:'<h3 style="text-align: center;color: #009E94"><i class="layui-icon" style="font-size: 30px; color: #009E94;">&#xe642;</i>学员评价</h3>',
                                        area:['500px','600px'],
                                        skin:'layui-open-setbgc',
                                        closeBtn: 0, //不显示关闭按钮
                                        shadeClose: true, //开启遮罩关闭
                                        content: content
                                    });
                                })
                        })

                },
                error:function () {
                    layui.use('layer', function() { //独立版的layer无需执行这一句
                        var $ = layui.jquery, layer = layui.layer;
                        layer.alert('<div style="text-align: center"><i class="layui-icon" style="font-size: 30px; color: #1E9FFF;">&#xe642</i>此订单还没有评价</div>');
                    })
                }
            })
        }


        function countBalance() {
            $.ajax({
                url:'/platForm/countBalance',
                type:'get',
                dataType:'json',
                success:function (data) {
                    var content='<div class="layui-row" style="float: left; width: 70%;height: 800px">'
                        +'<div class="layui-col-xs12" style="text-align: center; margin-top: 100px;" >'
                        +'<i class="layui-icon layui-icon-rmb" style="font-size: 70px; color: orange;"></i>'
                        +'</div>'
                        +'<div class="layui-col-xs12" style="text-align: center; margin-top: 30px; font-size: 16px">账户余额</div>'
                        +'<div class="layui-col-xs12" style="text-align: center; margin-top: 40px; font-size: 35px;font-weight: 700;">'
                        +'￥&nbsp;<label>'+data+'</label>'
                        +'</div>'
                        +'<div class="layui-col-xs12" style="text-align: center; margin-top: 40px; font-size: 16px">'
                        +'</div>'
                        +'</div>';
                    $("#mainContent").html(content);
                }
            })
        }


        function findContracts(currentPage){
            $.ajax({
                url:'/platForm/findContracts',
                type:'get',
                data:{
                    page:currentPage,
                },
                dataType:'json',
                success:function (data) {
                    var content='<table class="table table-bordered table-hover" style="width: 1800px;float: left;">'
                        +'<thead>'
                        +'<tr style="background-color: #545b62">'
                        +'<th>#</th>'
                        +'<th>学员姓名</th>'
                        +'<th>教练姓名</th>'
                        +'<th>场馆名</th>'
                        +'<th>平台抽成比例</th>'
                        +'<th>场馆抽成比例</th>'
                        +'<th>保证金</th>'
                        +'<th>合约状态</th>'
                        +'<th>合约时间</th>'
                        +'</tr>'
                        +'</thead>'
                        +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){
                        var po=data.rows[i];
                        var oStates='';
                        if(po.cStateChinese=='未处理'){
                            oStates='<td><div style="width: 50px;height: 20px;background-color: #e0a800; margin-left: 40px;color: white">'+po.cStateChinese+'</div></td>'
                        }else if(po.cStateChinese=='进行中'){
                            oStates='<td><div style="width: 50px;height: 20px;background-color: #5FB878; margin-left: 40px;color: white">'+po.cStateChinese+'</div></td>'
                        }else if(po.cStateChinese=='已拒绝'){
                            oStates='<td><div style="width: 50px;height: 20px;background-color: #dc3545; margin-left: 40px;color: white">'+po.cStateChinese+'</div></td>'
                        }else if(po.cStateChinese=='已完成'){
                            oStates='<td><div style="width: 50px;height: 20px;background-color: #009E94; margin-left: 40px;color: white">'+po.cStateChinese+'</div></td>'
                        }else if(po.cStateChinese=='已取消'){
                            oStates='<td><div style="width: 50px;height: 20px;background-color: #6c757d; margin-left: 40px;color: white">'+po.cStateChinese+'</div></td>'
                        }
                        content+='<tr style="color: black">'
                            +'<td>'+po.cId+'</td>'
                            +'<td>'+po.sName+'</td>'
                            +'<td>'+po.cName+'</td>'
                            +'<td>'+po.gName+'</td>'
                            +'<td>'+po.cGaPlatformratio+'</td>'
                            +'<td>'+po.cTaGymratio+'</td>'
                            +'<td>'+po.cBanlance+'</td>'
                            + oStates
                            +'<td>'+po.cCreatetime+'</td>'
                            +'</tr>'
                    }
                    content+='</tbody>'
                        +'</table>';
                    content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                        '<ul class="pagination">' +
                        '<li class="page-item"><a class="page-link" onclick="prePagefindContracts('+currentPage+')">前一页</a></li>';
                    for(var i=0;i<data.total;i++){
                        var page=i+1;
                        content+='<li class="page-item"><a class="page-link" onclick="findContracts('+page+')">'+page+'</a></li>'
                    };
                    content+='<li class="page-item"><a class="page-link" onclick="nextPagefindContracts('+currentPage+','+data.total+')">下一页</a></li>' +
                        '</ul>' +
                        '</div>';
                    $("#mainContent").html(content);
                }
            })
        }
        function nextPagefindContracts(currentPage,totalPage){
            if(currentPage<totalPage){
                findContracts(currentPage+1)
            }
        }
        function prePagefindContracts(currentPage){
            if(currentPage>1){
                findContracts(currentPage-1)
            }
        }

        function addGym() {
            var detail;
            var latlng;
            var address;
            var content='<div class="add_div">' +
                '    <div style="margin-top: 30px;margin-left: 40%;width: 500px">' +
                '        <h1 class="text-muted" style="text-align: center">添加场馆</h1>' +
                '        <form class="bs-example bs-example-form" role="form">' +
                '            <div class="input-group">' +
                '                <span class="input-group-btn">账号：</span>' +
                '                <input type="text" class="form-control" placeholder="11位手机号（必填）" id="account">' +
                '            </div>' +
                '            <div class="input-group">' +
                '                <span class="input-group-btn">密码：</span>' +
                '                <input type="text" class="form-control" placeholder="（必填）" id="password">' +
                '            </div>' +
                '            <div class="input-group">' +
                '                <span class="input-group-btn">馆名：</span>' +
                '                <input type="text" class="form-control" placeholder="（必填）" id="name">' +
                '            </div>' +
                '            <div class="input-group">' +
                '                <span class="input-group-btn">介绍：</span>' +
                '                <input type="text" class="form-control" placeholder="非必填" id="introduction">' +
                '            </div>' +
                '            <div class="input-group">' +
                '               <div class="layui-form-item" style="margin-left: 100px;">\n' +
                '                   <fieldset class="layui-elem-field layui-field-title" style="margin-top: -20px; width: 800px;margin-left: -300px">\n' +
                '                       <legend>请选择地址信息</legend>\n' +
                '                   </fieldset>\n' +
                '               </div>\n' +
                '               <iframe id="mapPage" width="100%" height="400px" frameborder=0 style="margin-top: -20px"\n' +
                '                    src="http://apis.map.qq.com/tools/locpicker?search=1&type=1&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myapp">\n' +
                '               </iframe>'+
                '            </div>' +
                '            <div class="input-group">' +
                '                <span class="input-group-btn">图片：</span>' +
                '                <input type="file" class="form-control" multiple="multiple" id="choose-file">' +
                '            </div>' +
                '            <p>' +
                '            <ul class="file-list ">' +
                '' +
                '            </ul>' +
                '            </p>' +
                '            <button type="button" style="cursor: pointer;margin-left: 200px;margin-top: 30px" id="upload" class="layui-btn">上传</button>' +
                '            <br>' +
                '        </form>' +
                '    </div>' +
                '</div>';
            $("#mainContent").html(content);
            window.addEventListener('message', function(event) {
                // 接收位置信息，用户选择确认位置点后选点组件会触发该事件，回传用户的位置信息
                var loc = event.data;
                if (loc && loc.module == 'locationPicker') {//防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
                    console.log('location', loc);
                    detail = loc.poiaddress;
                    console.log("detail",detail);
                    address=detail;
                    //获取经纬度并且赋值
                    var lat = loc.latlng.lat;
                    var lng = loc.latlng.lng;
                    //经纬度拼接
                    latlng = lat+","+lng;
                    console.log("latlng","latlng是："+latlng);
                }
            }, false);
            ////////////////////////////////////////////////图片上传//////////////////////////////////////////////
            //声明变量
            var $button = $('#upload'),
                //选择文件按钮
                $file = $("#choose-file"),
                //回显的列表
                $list = $('.file-list'),
                //选择要上传的所有文件
                fileList = [];
            //当前选择上传的文件
            var curFile;
            // 选择按钮change事件，实例化fileReader,调它的readAsDataURL并把原生File对象传给它，
            // 监听它的onload事件，load完读取的结果就在它的result属性里了。它是一个base64格式的，可直接赋值给一个img的src.
            $file.on('change', function (e) {
                // //上传过图片后再次上传时限值数量
                // var numold = $('li').length;
                // alert(numold);
                // if(numold >= 6){
                //     alert('最多上传6张图片');
                //     return;
                // }
                //限制单次批量上传的数量
                // var num = e.target.files.length;
                // var numall = numold + num;
                // if(num >6 ){
                //     alert('最多上传6张图片');
                //     return;
                // }else if(numall > 6){
                //     alert('最多上传6张图片');
                //     return;
                // }
                //原生的文件对象，相当于$file.get(0).files;//files[0]为第一张图片的信息;
                curFile = this.files;
                //curFile = $file.get(0).files;
                //console.log(curFile);
                //将FileList对象变成数组
                fileList = fileList.concat(Array.from(curFile));
                //console.log(fileList);
                for (var i = 0, len = curFile.length; i < len; i++) {
                    reviewFile(curFile[i])
                }
                $('.file-list').fadeIn(2500);
            })


            function reviewFile(file) {
                //实例化fileReader,
                var fd = new FileReader();
                //获取当前选择文件的类型
                var fileType = file.type;
                //调它的readAsDataURL并把原生File对象传给它，
                fd.readAsDataURL(file);//base64
                //监听它的onload事件，load完读取的结果就在它的result属性里了
                fd.onload = function () {
                    if (/^image\/[jpeg|png|jpg|gif]/.test(fileType)) {
                        $list.append('<li class="file-item"><img src="' + this.result + '" alt="" height="70"><span class="file-del"><button type="button" class="layui-btn layui-btn-normal">删除</button></span></li>').children(':last').hide().fadeIn(2500);
                    } else {
                        $list.append('<li class="file-item"><span class="file-name">' + file.name + '</span><span class="file-del">删除</span></li>')
                    }

                }
            }

            //点击删除按钮事件：
            $(".file-list").on('click', '.file-del', function () {
                let $parent = $(this).parent();
                console.log($parent);
                let index = $parent.index();
                fileList.splice(index, 1);
                $parent.fadeOut(850, function () {
                    $parent.remove()
                });
            });
            //点击上传按钮事件：
            $button.on('click', function () {
                var account = $('#account').val();
                var password = $('#password').val();
                var name = $('#name').val();
                var introduction = $('#introduction').val();

                layui.use('layer', function(){ //独立版的layer无需执行这一句
                    var $ = layui.jquery, layer = layui.layer;
                    if (account==''||account.length!=11) {
                        layer.msg('场馆账号应为11位的手机号，请核实后重新输入', {icon: 5,anim:6})
                    }else if (password == '') {
                        layer.msg('场馆密码不能为空', {icon: 5,anim:6})
                        return;
                    }else if (name == '') {
                        layer.msg('请输入场馆名称', {icon: 5,anim:6})
                        return;
                    }
                    if(fileList.length > 10){
                        layer.alert('最多允许上传10张图片');
                        return;
                    } else {
                        var formData = new FormData();
                        fileList.forEach(function (file) {
                            formData.append('file', file, file.name);
                        })
                        formData.append('gAccount', account);
                        formData.append('gPassword', password);
                        formData.append('gName', name);
                        formData.append('gIntroduction', introduction);
                        formData.append('gLatlng',latlng);
                        formData.append('gAddress',address);
                        formData.append('gBanlance',0);
                        var returnData='';
                        $.ajax({
                            url: '/platForm/addGym',
                            type: 'post',
                            data: formData,
                            processData: false,
                            contentType: false,
                            success:function (data) {
                                layer.alert(data);
                            },
                        });
                        // layui.use('layer', function(){ //独立版的layer无需执行这一句
                        //     var $ = layui.jquery, layer = layui.layer;
                        //
                        // })
                    }
                })

            })
        }
    </script>

    <!--头部-->
    <header class="header" id="header"></header>
    <!--侧边栏-->
    <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="demo" style="float: left; height:1000px;width: 14%">
        <li class="layui-nav-item layui-nav-itemed">
            <a href="javascript:;">场馆</a>
            <dl class="layui-nav-child">
                <dd><a href="javascript:;" onclick="findGyms(1)">所有场馆</a></dd>
                <dd><a href="javascript:;" onclick="addGym()">添加场馆</a></dd>
                <dd><a href="javascript:;" onclick="findGymSignRequest(1)">审核场馆签约请求</a></dd>
                <dd><a href="javascript:;"onclick="findGymSignRequestForRescission(1)">与场馆解约</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item">
            <a href="javascript:;">教练</a>
            <dl class="layui-nav-child">
                <dd><a href="javascript:;" onclick="findTrainersByStateOne(1)">平台认证教练</a></dd>
                <dd><a href="javascript:;" onclick="findTrainersByStateZero(1)">教练资质审核</a></dd>
                <dd><a href="javascript:;" onclick="findTrainersByStateTwo(1)">已禁用教练</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item"><a href="javascript:;" onclick="findStudents(1)">所有注册用户</a></li>
        <li class="layui-nav-item"><a href="javascript:;" onclick="findOrders(1)">所有订单</a></li>
        <li class="layui-nav-item"><a href="javascript:;" onclick="findContracts(1)">所有合约</a></li>
        <li class="layui-nav-item"><a href="javascript:;" onclick="countBalance()">余额</a></li>
    </ul>
    <!--局部刷新框-->
    <div id="mainContent">

    </div>
</body>
</html>